@extends('home.application.layouts')
@section('mainw12')
<section class="main w12">
    <div class="title"><a class="title1 db fl">申请成为作者</a><!-- <a class="title2 db fl">个人会员</a> --></div>
    <div class="fr tit2"><span class="arr"></span></div>
    <div class="w12 step" style="background: url('{{asset('assets/application/images/3_03.jpg')}}') center 55% no-repeat;"></div>
    <div class="inputsec">
        <ul>
            <li>
                <label class="fl mr2">年龄：</label>
                <input type="number" tabindex="3" min="15" max="150" name="age" id="age"  style="ime-mode:disabled" class="txt-m fl " placeholder="请输入年龄" onClick="if(value==defaultValue){value='';this.style.color='#333'}" >
            </li>
            <li>
                <label class="fl mr2">性别：</label>
                <input type="radio" name="sex" value="1">男
                <input type="radio" name="sex" value="2">女
            </li>
            <li>
                <label class="fl mr2">学历：</label>
                <input type="radio" name="education" value="1">小学
                <input type="radio" name="education" value="2">初中
                <input type="radio" name="education" value="3">高中
                <input type="radio" name="education" value="4">大学
                <input type="radio" name="education" value="5">大学以上
            </li>
            <li>
                <label class="fl mr2">职业：</label>
                <input type="text" tabindex="3" name="work" id="work"  style="ime-mode:disabled" class="txt-m fl " placeholder="请输入从事职业" onClick="if(value==defaultValue){value='';this.style.color='#333'}" >
            </li>
            <input type="hidden" name="d" value="" id="d">
            <li>
                <label class="fl mr2">省：</label>
                <select name="Provincial"  id="Provincial" class="txt-m fl ">
                </select>
            </li>
            <li>
                <label class="fl mr2">市/区：</label>
                <select name="City"  id="City" class="txt-m fl ">
                </select>
            </li>
            <li>
                <label class="fl mr2">县/乡：</label>
                <select name="Country"  id="Country" class="txt-m fl ">
                </select>
            </li>
            <li class="clr"><label class="db fl">&nbsp;</label><button class="db fl next yiyiu yiyius" style="border: none;" onclick="checkup()">下一步</button></li>
        </ul>
    </div>
</section>
    @endsection
@section('javascript')
<script type="text/javascript">

    $(function(){
        $.get('{{url('getaddress/0')}}',function(data){
            $("#Provincial").html("<option value=''>请选择省份</option>");
            $.each(data, function(i,item) {
                $("#Provincial").append("<option value='" + item.id + "'>" + item.name + "</option>");
            });
        });
        $("#Provincial").change(function() {
            $.get('{{url('getaddress')}}/'+$(this).val(),function(data){
                $("#City").html("<option value='' disabled>请选择市/区</option>");
                $.each(data, function(i, item) {
                    $("#City").append("<option value='" + item.id + "'>" + item.name+ "</option>");
                });
            })
        });
        $("#City").change(function() {
            $.get('{{url('getaddress')}}/'+$(this).val(),function(data){
                $("#Country").html("<option value='' disabled>请选择县/乡/街道</option>");
                $.each(data, function(i, item) {
                    $("#Country").append("<option value='" + item.id + "'>" + item.name+ "</option>");
                });
            })
        });
    });
    function checkup(){

        var Provincial=$('#Provincial option:selected').val();
        var City=$('#City option:selected').val();
        var Country=$('#Country option:selected').val();
        var education=$('input[name="education"]:checked').val();
        var sex=$('input[name="sex"]:checked').val();
        var age=$("#age").val();
        var work=$("#work").val();
//        alert(Country);
        var msg='';
        if(age>150 || age<15 || age==''){
            msg+='年龄错误';
        }
        if(City==undefined){
            msg+=',地址错误';
        }
        if(msg!=''){
            layer.alert(msg);
            return 0;
        }
        $.post('{{url('application2')}}',{'_token':'{{csrf_token()}}','education':education,'age':age,'work':work,'sex':sex,'address':Provincial+'-'+City+'-'+Country},function(res){
            if(res.status){
                location.href='{{url('application3')}}';
            }else{
                layer.msg(res.msg)
            }
        });
    }
</script>
</body>
</html>
@endsection